package com.jeesite.modules.config.web;

import com.jeesite.common.codec.DesUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Map;

@ConfigurationProperties(prefix = "weixin")
public class WeixinProperties implements InitializingBean {

  private Boolean enable = false;
  private String appId;
  private String secret;
  private String encryptSecret;
  private String token;
  private String aesKey;
  private String redirectUrl;
  /** 注册用户 url */
  private String registerUrl;
  /** 微信身份验证后 重定向地址 */
  private String authedUrl;
  private String baseUrl;

  private Map<String, String> entries;
  private Map<String, String> templates;

  @Override
  public void afterPropertiesSet() throws Exception {
    this.secret = DesUtils.decode(encryptSecret, "fule-medical");
  }

  public static void main(String[] args) {
    String enc = DesUtils.encode("3", "fule-medical");
    System.out.println(enc);
    System.out.println(DesUtils.decode(enc, "fule-medical"));
  }

  public Boolean getEnable() {
    return enable;
  }

  public void setEnable(Boolean enable) {
    this.enable = enable;
  }

  public String getAppId() {
    return appId;
  }

  public void setAppId(String appId) {
    this.appId = appId;
  }

  public String getEncryptSecret() {
    return encryptSecret;
  }

  public void setEncryptSecret(String encryptSecret) {
    this.encryptSecret = encryptSecret;
  }

  public String getSecret() {
    return secret;
  }

  public String getRedirectUrl() {
    return redirectUrl;
  }

  public void setRedirectUrl(String redirectUrl) {
    this.redirectUrl = redirectUrl;
  }

  public String getRegisterUrl() {
    return registerUrl;
  }

  public void setRegisterUrl(String registerUrl) {
    this.registerUrl = registerUrl;
  }

  public String getToken() {
    return token;
  }

  public void setToken(String token) {
    this.token = token;
  }

  public String getAesKey() {
    return aesKey;
  }

  public void setAesKey(String aesKey) {
    this.aesKey = aesKey;
  }

  public String getAuthedUrl() {
    return authedUrl;
  }

  public void setAuthedUrl(String authedUrl) {
    this.authedUrl = authedUrl;
  }

  public String getBaseUrl() {
    return baseUrl;
  }

  public void setBaseUrl(String baseUrl) {
    this.baseUrl = baseUrl;
  }

  public Map<String, String> getEntries() {
    return entries;
  }

  public void setEntries(Map<String, String> entries) {
    this.entries = entries;
  }

  public Map<String, String> getTemplates() {
    return templates;
  }

  public void setTemplates(Map<String, String> templates) {
    this.templates = templates;
  }
}
